package cn.kgc.bilibili.controller;

import cn.kgc.bilibili.service.DongmanService;
import cn.kgc.bilibili.vo.DongmanVo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class DongmanController {


    @Resource
    DongmanService dongmanService;


    @GetMapping("/getDmByUpTime")
    public DongmanVo getDmByUpTime(@RequestParam(value = "updatetime", required = true, defaultValue = "1") Integer updatetime) {
        DongmanVo dongmanVo = new DongmanVo();
        try {
            dongmanVo.setList(dongmanService.getDongmanByUpdateTime(updatetime));
            dongmanVo.setMsg("查询成功!!");
            dongmanVo.setStatus(true);
        } catch (Exception e) {
            dongmanVo.setStatus(false);
            dongmanVo.setMsg("查询失败！！" + e.getMessage());
        }
        return dongmanVo;
    }


    @GetMapping("/getDmByHotNum")
    public DongmanVo getDmByHotnum() {
        DongmanVo dongmanVo = new DongmanVo();
        try {
            dongmanVo.setList(dongmanService.getDongmanByHotnum());
            dongmanVo.setMsg("查询成功!!");
            dongmanVo.setStatus(true);
        } catch (Exception e) {
            dongmanVo.setStatus(false);
            dongmanVo.setMsg("查询失败！！" + e.getMessage());
        }
        return dongmanVo;
    }
}
